/**
 * @param {number[]} students
 * @param {number[]} sandwiches
 * @return {number}
 */
 var countStudents = function(students, sandwiches) {
   let n = students.length
  let i = 0,count = 0
  while(sandwiches.length>0 &&students.includes(sandwiches[0]) ){
    if(students[i]==sandwiches[0]){
      students.splice(i,1)
      count++
      sandwiches.splice(0,1)
    }else {
      let temp = students[0]
      students.splice(0,1)
      students.push(temp)
    }
  }
  return n-count
};

countStudents([1,1,0,0],[0,1,0,1])